package com.pd.backend.controller;

import com.pd.backend.dtos.PdCoreOrgDto;
import com.pd.backend.dtos.ResponseResult;
import com.pd.backend.service.PdCoreOrgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 组织(部门)控制层
 * @Auther : 菜鸡编程
 * @Date:2023/1/12
 * @Description:
 * @VERSON:1.8
 */
@RestController
@Slf4j
@RequestMapping(path = "/pdCoreOrg")
@Api(tags = "组织部门")
public class PdCoreOrgController {

    @Autowired
    private PdCoreOrgService pdCoreOrgService;

    /**
     * 机构作业范围列表
     * @return
     */
    @ApiOperation("机构作业范围列表")
    @GetMapping("/tree/list")
    public ResponseResult pdCoreOrgGetTreeList(String name){
        return pdCoreOrgService.pdCoreOrgGetTreeList(name);
    }


    /**
     * 新建组织
     * @param pdCoreOrgDto
     * @return
     */
    @ApiOperation("新建组织")
    @PostMapping("/add/pdCoreOrg")
    public ResponseResult addPdCoreOrg(@RequestBody PdCoreOrgDto pdCoreOrgDto){
        return pdCoreOrgService.addPdCoreOrg(pdCoreOrgDto);
    }


    /**
     * 根据组织id查询组织
     * @param id
     * @return
     */
    @ApiOperation("根据组织id查询组织")
    @GetMapping("/selectPdCoreOrg/id")
    public ResponseResult selectPdCoreOrgById(Long id){
        return pdCoreOrgService.selectPdCoreOrgById(id);
    }



}
